﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Data;
using System.Collections;

namespace JoyWeb
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "Default0", // 路由名称
                "", // 带有参数的 URL
                new { controller = "Index", action = "index", id = UrlParameter.Optional } // 参数默认值
            );
            routes.MapRoute(
                "Default1", // 路由名称
                "index.html", // 带有参数的 URL
                new { controller = "Index", action = "Index" } // 参数默认值
            );
            routes.MapRoute(
                "login", // 路由名称
                "login.html", // 带有参数的 URL
                new { controller = "Login", action = "Login" } // 参数默认值
            );
            routes.MapRoute(
                "Default", // 路由名称
                "{controller}/{action}.html", // 带有参数的 URL
                new { controller = "Home", action = "Index"} // 参数默认值
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

 

            if (Application["UserOnline"] == null)//判断一个用户只能在一个地方登录实现
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("username");
                dt.Columns.Add("lasttime");
                dt.Columns.Add("userip");
                Application["UserOnline"] = dt;
            }
        }
    }
}